﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KeaoBase;

namespace KeaoMDS.Auth
{
    public partial class XiuGaiMiMa : BaseForm
    {
        public XiuGaiMiMa()
        {
            InitializeComponent();
        }

        private void menu_1_baocun_Click(object sender, EventArgs e)
        {
            //修改密码
            if (string.IsNullOrEmpty(txt_mimaqueren.Text) || string.IsNullOrEmpty(txt_xinmima.Text) || string.IsNullOrEmpty(txt_yuanshimima.Text))
            {
                return;
            }
            if (!KeaoUtils._CurrentUserRow["yonghumima"].Equals(KeaoUtils.Encrypt(txt_yuanshimima.Text)))
            {
                KeaoUtils.ShowInfoMessage("原始密码错误。");
                return;
            }
            if (txt_xinmima.Text != txt_mimaqueren.Text)
            {
                KeaoUtils.ShowInfoMessage("密码与密码确认不一致。");
                return;
            }
            TableRow editRow = new TableRow("tbl_yonghu",KeaoUtils._CurrentUserRow["id"].ToString(), DBCtl.修改);
            editRow.DataCols.Add(new TableCol() { ColName="yonghumima", ValueMember=KeaoUtils.Encrypt(txt_xinmima.Text), ValueType= DataValueCommonType.字符串 });
            editRow.DataCols.Add(new TableCol() { ColName = "shangchuanzhuangtai", ValueMember = "0", ValueType = DataValueCommonType.字符串 });
            if (KeaoUtils._DB.SaveTableRows(editRow) > 0)
            {
                DialogResult = DialogResult.OK;
            }
        }

        private void menu_1_guanbi_Click(object sender, EventArgs e)
        {
            //关闭系统
            this.Close();
        }

        private void txt_mimaqueren_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                menu_1_baocun_Click(null, null);
            }
        }

    }
}
